<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<h2>거래처 목록</h2>

<form method="get" action="" class="searchForm" onsubmit="return pageList.submit(); return false;">
<table class="searchQueryTb tb_search">
	<tbody>
		<tr>
			<th>시설명</th>
			<td>
				<input type="text" title="시설명" class="query" name="buildingNameTxt" value="${pageParam.buildingNameTxt}"/>
			</td>
			<th>사업자번호</th>
			<td>
				<input type="text" title="사업장번호" class="query" name="companyNumberTxt" value="${pageParam.companyNumberTxt}"/>
			</td>
			<th>대표자</th>
			<td>
				<input type="text" title="대표자" class="query" name="companyPresidentTxt" value="${pageParam.companyPresidentTxt}"/>
			</td>
		</tr>
		<tr>
			<th>측정대상구분</th>
			<td>
				<select name="measureTargetCd" title="측정대상구분" class="query">
					<option value="">전체</option>
					<c:forEach items="${measureTargetList}" var="item">
						<option value="${item.code}"<c:if test="${pageParam.measureTargetCd == item.code}">selected="selected"</c:if> >${item.name}</option>
					</c:forEach>
				</select>
			</td>
			<th>사업자명</th>
			<td>
				<input type="text" title="사업자명" class="query" name="companyNameTxt" value="${pageParam.companyNameTxt}"/>
			</td>
			<th>담당자</th>
			<td>
				<input type="text" title="담당자" class="query" name="inchargeNameTxt" value="${pageParam.inchargeNameTxt}"/>
			</td>
		</tr>
		<tr>
			<th>전화번호</th>
			<td>
				<input type="text" title="전화번호" class="query" name="telTxt" value="${pageParam.telTxt}"/>
			</td>
			<th>견적일</th>
			<td>
				<input type="text" title="견적일(조건시작일)" class="query dateRange" name="eDateStart" value="${pageParam.eDateStart}"/>
				~
				<input type="text" title="견적일(조건종료일)" class="query dateRange" name="eDateEnd" value="${pageParam.eDateEnd}"/>
			</td>
			<th>측정일</th>
			<td>
				<input type="text" title="측정일(조건시작일)" class="query dateRange" name="mDateStart" value="${pageParam.mDateStart}"/>
				~
				<input type="text" title="측정일(조건종료일)" class="query dateRange" name="mDateEnd" value="${pageParam.mDateEnd}"/>
			</td>
		</tr>
		<tr>
			<th>주소</th>
			<td colspan="6">
				<input type="text" title="주소" class="query addr" name="buildingAddrTxt" value="${pageParam.buildingAddrTxt}"/>
			</td>
		</tr>
		<tr>
			<th>검색어</th>
			<td colspan="6">
				<input type="text" title="검색어" class="query addr" name="commonQuery" value="${pageParam.commonQuery}"/>
				<br/>
				* 시설명, 사업자명, 사업자번호, 대표자, 담당자, 시설주소 에 해당하는 결과물을 출력한다.
			</when>
			</td>
		</tr>
		<tr>
			<td colspan="6" class="textR">
				<input type="hidden" name="pageNum" value="${pageParam.pageNum}"/>
				<input type="hidden" name="orderBy" value="${pageParam.orderBy}"/>
				<input type="hidden" name="logMsg" />
				<span class="button medium"><button type="submit" >조회</button></span>
			</td>
		</tr>
	</tbody>
</table>

<div class="clearfix searchBtn">
	<div class="floatR">
		<span class="button medium"><a href="<c:url value='/companyExcel'/>" class="excelDown">엑셀다운</a></span>
		<span class="button medium"><button type="button" id="printView">화면 출력</button></span>
		<c:if test="${userSession.role==0}">
			<span class="button medium"><a href="<c:url value='/form'/>">등록</a></span>
			<span class="button medium icon"><span class="delete"></span><button id="dataAllDelete">실데이터 전체삭제</button></span>
		</c:if>
	</div>
</div>

<div class="clearfix btn5">
	<div class="floatL">
		<span class="pageDataTotal">총 <strong>${pageDataTotal}</strong> 건</span>
	</div>
	<div class="floatR">
		<select name="pageCut" class="ui-widget-content ui-corner-all" >
			<c:forEach begin="10" end="50" step="5" var="cutNum">
				<option value="${cutNum}" <c:if test="${pageParam.pageCut==cutNum}">selected="selected"</c:if>>${cutNum}</option>
			</c:forEach>
		</select>
	</div>
</div>

<c:set var="loopIndex" value="${pageParam.startNum}"/>
<c:if test="${loopIndex > 1}"><c:set var="loopIndex" value="${loopIndex-1}"/></c:if>
<table id="searchDataList" class="searchDataList tb_list">
	<thead>
		<tr>
			<th scope="row" class="order" filed="building_name"><span>시설명</span></th>
			<th scope="row" class="order" filed="estimat_date"><span>견적일</span></th>
			<th scope="row" class="order" filed="measure_date"><span>측정일</span></th>
			<th scope="row" class="order" filed="measure_target"><span>구분</span></th>
<!-- 			<th scope="row" class="order" filed="company_name"><span>사업자명</span></th> -->
			<th scope="row" class="order" filed="building_addr"><span>구주소</span></th>
			<th scope="row" class="order" filed="incharge_name"><span>담당자</span></th>
<!-- 			<th>부서</th> -->
			<th>직위</th>
			<th>전화</th>
			<th>핸드폰</th>
			<th>팩스</th>
<!-- 			<th>메일</th> -->
		</tr>
	</thead>
	<tbody binText="측정 가능한 시설이 없습니다.">
		<c:choose>
			<c:when test="${!empty pagingList}">
				<c:forEach items="${pagingList}" var="item" varStatus="loop">
		            <tr>
		                <td><a href="form?buildingCd=${item.building_cd}">${item.building_name}</a></td>
		                <td class="textC"><span>${item.estimat_date}</span></td>
		                <td class="textC"><span>${item.measure_date}</span></td>
		                <td>${item.measure_target_txt}</td>
<%-- 		                <td>${item.company_name}</td> --%>
		                <td>${item.building_addr}</td>
		                <td>${item.incharge_name}</td>
<%-- 		                <td>${item.incharge_department}</td> --%>
		                <td>${item.incharge_rank}</td>
		                <td>${item.incharge_tel}</td>
		                <td>${item.incharge_phone}</td>
		                <td>${item.incharge_fax}</td>
<%-- 		                <td>${item.incharge_email}</td> --%>
		            </tr>
		        </c:forEach>
			</c:when>
			<c:otherwise>
				<tr>
					<td scope="col" colspan="13" class="bin">측정 가능한 시설이 없습니다.</td>
				</tr>
			</c:otherwise>
		</c:choose>
	</tbody>
</table>
<c:import url="../layout/paginate.jsp"></c:import>

</form>
<script type="text/javascript" src="<c:url value='/res/js/jquery/printThis.js'/>"></script>
<script type="text/javascript" src="<c:url value='/res/js/content/pageList.js'/>"></script>
<script type="text/javascript" src="<c:url value='/res/js/content/building/list.js'/>"></script>

